package com.yan.crowd.controller;

import com.yan.crowd.api.MysqlRemoteService;
import com.yan.crowd.constant.CrowdConstant;
import com.yan.crowd.entity.vo.PortalTypeVO;
import com.yan.crowd.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class PortalController {

    @Autowired
    private MysqlRemoteService mysqlRemoteService;

    @RequestMapping("/")
    public String showPortalPage(Model model){

        ResultEntity<List<PortalTypeVO>> portalTypeVO = mysqlRemoteService.getPortalTypeVO();

        String result = portalTypeVO.getResult();
        if (ResultEntity.SUCCESS.equals(result)){
            List<PortalTypeVO> data = portalTypeVO.getData();
            model.addAttribute(CrowdConstant.ATTR_NAME_PORTAL_DATA,data);
        }

        return "index";
    }

}
